home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d7 / lanuts.arc / RXMCOM.ASM < prev    next >
Assembly Source File  |  1991-10-30  |  8KB  |  280 lines

  1.  INCLUDE \ASM\INCLUDE\BIOS.INC
  2. INCLUDE DEFS.INC
  3.  
  4. MSG_OFFS EQU    66            ; position of message text in buffer
  5. BIOS_SEG EQU    0040h            ; seg address of BIOS data area
  6. KBD_HEAD EQU    01Ah            ; offset of keyboard head ptr
  7. KBD_TAIL EQU    01Ch            ; offset of keyboard tail ptr
  8.  
  9. LOGOUT_SERVICE    EQU    80h
  10. RUN_SERVICE    EQU    81h
  11.  
  12. msv    SEGMENT
  13.     ASSUME  CS:msv
  14.     ASSUME  DS:msv
  15.     ASSUME  ES:msv
  16.     ASSUME  SS:NOTHING
  17.     ORG    0
  18. SEG_ORG    EQU    $    
  19.     ORG    100h
  20. main    PROC    FAR
  21. start:    jmp    init            ; Do initialization section
  22.  
  23. ;*******************************************************************
  24. ; LANOS VECTOR TSR portion of Resident Extensions
  25. ; The LANOS portion simply sets a message received flag and
  26. ; exits, leaving the actual processing of the message to an
  27. ; interrupt.
  28. ;*******************************************************************
  29. MSV_entry:    jmp first            ; skip data area
  30. msg_flag    db    0
  31. kbd_busy    db    0            ; still stuffin' that buffer
  32. kbd_index    dw    0            ; current position in string
  33. msg_state    db    0            ; storage for old msg flag
  34. msg_address     dd    ?            ; message address data
  35. old_msr        dd    ?            
  36. old_vector2     dd    ?            ; old DOS service vector
  37.  
  38. old_stk_seg    dw      ?               ; Calling program's stack info
  39. old_b_ptr    dw    ?
  40. old_stk_ptr    dw      ?
  41. new_stk_seg    dw      ?
  42. new_stk_ptr    dw    OFFSET TOS
  43.         dw    60 dup (?)    ; local stack data area
  44. TOS        equ    $        
  45.  
  46. ;************************************************************************
  47. ; Start of actual LANOS message handler. This message handler should
  48. ; be loaded last.
  49. ;************************************************************************
  50. first:  
  51.     push    ax            ; save the regs we're gonna use
  52.     mov    word ptr cs:msg_address,bx    ; save address of incoming message
  53.     mov    word ptr cs:msg_address + 2,es
  54.     
  55.     mov    al,es:[bx]+1        ; get the MB_type field
  56.     cmp    al,80h            ; is it for us?
  57.     jl      END_MSH            ; if less than 80h it's not ours
  58.     
  59.     mov    cs:msg_flag,al        ; save the message type.
  60.     pop    ax                      ; restore ax
  61.     iret                ; back to originally scheduled program
  62.     
  63. END_MSH:
  64.     pop    ax            ; restore AX register
  65.     jmp    cs:old_msr              ; call everyone else...
  66.  
  67. ;*****************************************************************************
  68. ; Interrupt E0 handler --- this is apparently something that LANtastic uses
  69. ; internally to indicate when DOS is safe.
  70. ;*****************************************************************************
  71. INT_E0             DD   0
  72. DOSFREE:
  73.     PUSHF
  74.     CALL CS:old_vector2                 ; give everyone else a chance...
  75.     
  76.     push ax                ; save the regs we're using
  77.     push dx
  78.     mov    al,cs:msg_flag            ; get message flag
  79.  
  80.     cmp  al,0                           ; have our services been requested?
  81.     jz   Done_E0            ; If not, skip this stuff
  82.  
  83. CHK_LOGOUT:
  84.     cmp    al,LOGOUT_SERVICE        ; is it a logout request?
  85.     jne    CHK_RUN                ; if not, continue
  86.     
  87.     call logout                ; execute the logout
  88.     mov     cs:msg_flag,0            ; reset the message flag
  89.     jmp  Done_E0            ; all done.
  90.     
  91. CHK_RUN:
  92.     cmp al,RUN_SERVICE            ; is it a remote RUN request?        
  93.     jne Done_E0
  94.     
  95.     cmp    cs:kbd_busy,0            ; are we already stuffing the buffer?
  96.     jnz    DO_RUN
  97.  
  98.     inc    cs:kbd_busy            ; set the busy flag
  99.     mov    cs:kbd_index,66            ; set our string pointer to the text.
  100.     
  101. DO_RUN:
  102. ; Note -- stuff_buffer is responsible for clearing msg_flag and kbd_busy when
  103. ; it has stuffed all the characters into the buffer and added a carriage 
  104. ; return
  105.  
  106.     call stuff_buffer            ; Enter a character into der buffer.
  107.  
  108. Done_E0:
  109.    pop  dx
  110.    pop    ax
  111.    iret
  112.     
  113. ;*****************************************************************************
  114. ; Logs the computer out of the specified server 
  115. ;*****************************************************************************
  116. logout    PROC    near
  117.         push    di
  118.         push    ax
  119.         push    es
  120.     
  121.     mov    di,word ptr cs:msg_address    ; put server name in ES:DI
  122.     add     di,MSG_OFFS                    ; point to message text
  123.     mov    ax,word ptr cs:msg_address+2
  124.     mov    es,ax
  125.     
  126.     mov    ax,5F82h        ; log out of the server
  127.     int    21h            ; do it!
  128.  
  129.     pop    es
  130.     pop    ax
  131.     pop    di
  132.     
  133.         ret
  134. logout    ENDP
  135.     
  136. ;*****************************************************************************
  137. ; Stuffs the specified command in the keyboard buffer, one key at a time.
  138. ;  
  139. ;*****************************************************************************
  140. Stuff_Buffer PROC    near 
  141.     @NewStack
  142.     cli                    ; forbid interrupts
  143.     
  144. ; Point DS to our command string buffer
  145.     mov    ax,word ptr cs:msg_address+2    ; point data segment to msg buffer
  146.     mov    ds,ax
  147.     
  148.     mov     si,word ptr cs:msg_address
  149.     add     si,cs:kbd_index                 ; get our offset
  150.  
  151.     mov    al,byte ptr ds:[si]        ; get the next character
  152.     
  153.     cmp    al,0                ; is it the terminator
  154.     jnz    Start_Stuff            ; if not, continue
  155.  
  156.     mov    cs:kbd_busy,0            ; clear keyboard busy flag
  157.     mov    cs:msg_flag,0            ; clear message flag
  158.     mov    al,13                ; convert char to return
  159.  
  160. ; point ES to the BIOS data area
  161. Start_Stuff:
  162.     mov     bx, BIOS_SEG    
  163.     mov     es, bx
  164.     
  165.     mov     bx, word ptr es:[KBD_TAIL]    ; is anything in the buffer?
  166.     cmp    bx, word ptr es:[KBD_HEAD]        
  167.     jnz    Done_Stuff            ; if so, then don't do anything
  168.  
  169.     inc    cs:kbd_index            ; point to the next char
  170.     
  171.     mov    es:[bx],ax            ; save the keystroke
  172.     inc    bx
  173.     inc    bx                ; move the tail pointer
  174.     cmp    bx,3Eh                ; check for buffer wrap
  175.     jl    Set_Kbd_Ptrs            ; have we wrapped?
  176.     mov    bx,1Eh                ; if so, back to start of buffer
  177. Set_Kbd_Ptrs:
  178.     mov    word ptr es:[KBD_TAIL],bx    ; set the keyboard buffer ptr.
  179.     
  180. Done_Stuff:
  181.      @OldStack    
  182.     ret
  183. Stuff_Buffer    ENDP    
  184.  
  185. LAST_BYTE    EQU $
  186.  
  187. ;
  188. ;    Initialization -- thrown away after load
  189. ;
  190.  
  191. ;*********************************************************************
  192. ; Subroutines
  193. ;********************************************************************
  194. PRT_STR    PROC    NEAR
  195. ;
  196. ; Write ASCIIZ string pointed to by ES:DI at current cursor position
  197. ;
  198. L3:
  199.     mov    al,es:[di]        ; get the character
  200.     or    al,al            ; See if it's a zero
  201.     jz    L4            ; Yes- we're done
  202.     mov    bx,7            ; display page 0, fg color 7
  203.     mov     ah,0Eh            ; Write char / tty mode
  204.     int     10h            ; Display the character
  205.     inc    di            ; get the next char
  206.     jmp    short L3
  207. L4:
  208.     ret    
  209. PRT_STR    ENDP
  210.  
  211.  
  212.  
  213. title1    db    "    SoftMagic Resident Extension Module V1.0 for LANtastic",13,10,0
  214. title2    db    "Copyright 1990 by SoftMagic, Inc. All rights Reserved.",13,10,0
  215. title3    db    "     LANtastic is a trademark of Artisoft, Inc.",13,10,0
  216.  
  217. IFDEF    SHAREWARE
  218. title5  db      7,"Thanks for trying this unregistered ShareWare Version!",7,7,13,10,0
  219. ENDIF
  220.  
  221. init:
  222.     @NewStack            ; Set up local stack
  223.     push     cs
  224.     pop    es
  225.  
  226. ; Display title messge
  227.     mov     di,OFFSET title1
  228.     call    PRT_STR
  229.     mov    di,OFFSET title2
  230.     call    PRT_STR
  231.     mov    di,OFFSET title3
  232.     call     PRT_STR
  233.     
  234. IFDEF    SHAREWARE    
  235.     mov    di,OFFSET title5
  236.     call    PRT_STR
  237. ENDIF    
  238.  
  239. ; Get old LANOS message handler vector
  240.     mov     ax,5FE2h
  241.     int    21h
  242.     mov    word ptr old_msr,bx     ; Save the location of the old vector
  243.     mov    word ptr old_msr+2,es
  244.  
  245. ;
  246. ; Replace the LANOS message service
  247. ;
  248.     mov    ax,cs
  249.     mov    es,ax
  250.     mov    ax,5FE3h
  251.     mov    bx,OFFSET MSV_entry
  252.     int    21H
  253.  
  254. ;
  255. ; Replace LANtastic's internal DOS free vector
  256. ;
  257.     MOV  AX,5FE0H
  258.     INT  21H                            ; GET THE DOS FREE VECTOR
  259.     MOV  WORD PTR old_vector2,BX
  260.     MOV  WORD PTR old_vector2+2,ES
  261.  
  262. ;
  263. ; Set vector to our routine
  264. ;
  265.     push cs
  266.     pop  es    
  267.         MOV  BX,OFFSET DOSFREE
  268.         MOV  AX,5FE1H
  269.         INT  21H                           
  270.  
  271. ; Terminate and stay resident
  272.      @OldStack            ; Restore caller's stack
  273.      mov    dx,(offset LAST_BYTE - SEG_ORG + 15) shr 4
  274.      mov    ah,31h                  ; free memory and leave
  275.      int     21h
  276. main    ENDP
  277. msv    ENDS
  278. END    start                        
  279.                     
  280.